package cn.com.xinjinfu.pdoulcProduct.utils;

import android.content.Context;
import android.content.SharedPreferences;
/**
 * SharedPreferencesUtils 这个类主要是用来保存或�?获取数据的时候使�?
 **/
public class SharedPreferencesUtils {
	public static final String SP_NAME = "config";
	public static final String IS_FIRST = "first_pref";
	public static final String OFFICIAL_ID = "official_id";
	public static final String IS_SHOUSHI_PWD = "is_shoushi_pwd";
	private static SharedPreferences sp;

	public static  String getUserInfo(Context ct, String key) {
			sp = ct.getSharedPreferences(SP_NAME, 0);
		return sp.getString(key, "");
	}

	public static boolean saveUserInfo(Context ct, String key, String info) {
			sp = ct.getSharedPreferences(SP_NAME, 0);
		return sp.edit().putString(key, info).commit();
	}

	public static boolean saveOfficialId(Context ct, String key, String info) {
		sp = ct.getSharedPreferences(OFFICIAL_ID, 0);
		return sp.edit().putString(key, info).commit();
	}
	public static  String getOfficialId(Context ct, String key) {
		sp = ct.getSharedPreferences(OFFICIAL_ID, 0);
		return sp.getString(key, "");
	}
	public static void deleteUserInfo(Context ct){
		sp = ct.getSharedPreferences(SP_NAME, 0);
		sp.edit().clear().commit();
	}

	/***
	 * 是否第一次进入引导页面
	 * @param ct
	 * @param key
	 * @param value
	 */
	public static void saveBoolean(Context ct, String key, boolean value) {
			sp = ct.getSharedPreferences(IS_FIRST, 0);
		sp.edit().putBoolean(key, value).commit();
	}
	public static boolean getBoolean(Context ct, String key, boolean defValue) {
			sp = ct.getSharedPreferences(IS_FIRST, 0);
		return sp.getBoolean(key, defValue);
	}

	/**
	 * 保存是否设置过手势密码
	 * @param ct
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static boolean getPwdBoolean(Context ct, String key, boolean defValue) {
			sp = ct.getSharedPreferences(IS_SHOUSHI_PWD, 0);
		return sp.getBoolean(key, defValue);
	}

	public static void savePwdBoolean(Context ct, String key, boolean value) {
			sp = ct.getSharedPreferences(IS_SHOUSHI_PWD, 0);
		sp.edit().putBoolean(key, value).commit();
	}
	public static void deletePwdBoolean(Context ct){
		sp = ct.getSharedPreferences(IS_SHOUSHI_PWD, 0);
		sp.edit().clear().commit();
	}

}
